﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace BDSim
{
    /// <summary>
    /// ToolBarView.xaml 的交互逻辑
    /// </summary>
    public partial class ToolBarView : UserControl
    {
        public ToolBarView()
        {
            InitializeComponent();
        }

        #region 保存仿真场景【按钮事件】
        /// <summary>
        /// 保存仿真场景【按钮事件】
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            switch ((bool)e.NewValue)
            {
                case true:
                    ((Button)sender).Content = CreatImage("Save.png");
                    break;
                case false:
                    ((Button)sender).Content = CreatImage("Save_Unable.png");
                    break;
                default:
                    break;
            }
        }
        #endregion

        #region 创建一个Image对象
        /// <summary>
        /// 创建一个Image对象
        /// </summary>
        /// <param name="imageName"></param>
        /// <returns></returns>
        Image CreatImage(string imageName)
        {
            string ImagePath = @"/BDSim;component/Resources/Images/" + imageName;
            Image myImage3 = new Image();
            BitmapImage bi3 = new BitmapImage();
            bi3.BeginInit();
            bi3.UriSource = new Uri(ImagePath, UriKind.Relative);
            bi3.EndInit();
            myImage3.Stretch = Stretch.Fill;
            myImage3.Source = bi3;
            myImage3.Height = 18;
            myImage3.Width = 18;
            return myImage3;
        }
        #endregion

        #region 打开仿真场景使能变化事件
        /// <summary>
        /// 打开仿真场景使能变化事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOpen_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            switch ((bool)e.NewValue)
            {
                case true:
                    ((Button)sender).Content = CreatImage("OpenFolder.png");
                    break;
                case false:
                    ((Button)sender).Content = CreatImage("OpenFolder_Unable.png");
                    break;
                default:
                    break;
            }
        }
        #endregion

        #region 用户向导功能使能事件
        /// <summary>
        /// 用户向导功能使能事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnWizard_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            switch ((bool)e.NewValue)
            {
                case true:
                    ((Button)sender).Content = CreatImage("SysMsg.png");
                    break;
                case false:
                    ((Button)sender).Content = CreatImage("UnableWizard.png");
                    break;
                default:
                    break;
            }
        }
        #endregion

        #region 添加特定模型的使能事件
        /// <summary>
        /// 添加特定模型的使能事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddModel_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            switch ((bool)e.NewValue)
            {
                case true:
                    ((Button)sender).Content = CreatImage("add_16.png");
                    break;
                case false:
                    ((Button)sender).Content = CreatImage("add_16_Unable.png");
                    break;
                default:
                    break;
            }
        }
        #endregion

    }
}
